package T3;

public class Color {
    private int red;
    private int green;
    private int blue;

    public Color() {
        this(0,0,0);
    }

    public Color(int red, int green, int blue) {
       this.red = (red >= 0 && red <= 255) ? red : 0;
        this.green = (green >= 0 && green <= 255) ? green : 0;
        this.blue = (blue >= 0 && blue <= 255) ? blue : 0;
    }

    public int getRed() {
        return red;
    }

    public void setRed(int red) {
       this. red = ((red >= 0) && (red <= 255)) ? red : 0;//this. 成员变量
    }

    public int getGreen() {
        return green;
    }

    public void setGreen(int green) {
        this.green = (green >= 0 && green <= 255) ? green : 0;
    }

    public int getBlue() {
        return blue;
    }

    public void setBlue(int blue) {
        this.blue = (blue >= 0 && blue <= 255) ? blue : 0;
    }
}
